#ifndef __DOWNLOAD_H__
#define __DOWNLOAD_H__

#include <curl/curl.h>

#include <memory>
#include <string>

#include "thread_pool.h"

class Downloader
{
  public:
    virtual ~Downloader() = default;

    static std::unique_ptr<Downloader> create(const std::string &url, ThreadPool &, ThreadPool &);

    virtual error_t work(const std::string &url, const std::string &output) = 0;

  protected:
    // 获取文件大小(如使用http的head方法检查)
    virtual error_t getFileSize(const std::string &url, long &fileSize) = 0;

    // 检查是否支持range(如http协议)
    virtual bool checkRangeSupport(const std::string &url) = 0;
};

#endif  //__DOWNLOAD_H__